﻿#region System Namespace
using System;
using System.Linq;
using System.Threading;
#endregion System Namespace

#region Foreign Namespace
#endregion Foreign Namespace

#region Styx Namespace
using Styx;
using Styx.Plugins;
using Styx.WoWInternals.WoWObjects;
using Styx.CommonBot.Frames;
using Styx.WoWInternals;
#endregion Styx Namespace

namespace Auction
{
    public partial class Auction : HBPlugin
    {
        public void Query()
        {
            foreach (WoWItem item in StyxWoW.Me.BagItems.Where(item => item != null))
            {
                try
                {
                    if (new AuctionFrame().IsVisible && StyxWoW.Me.BagItems != null)
                    {
                        Log("Updating prices for items in bags");
                        Random r = new Random();
                        Lua.DoString("RunMacroText(\"/click IMA_QueryAllButton\")");
                        Thread.Sleep(r.Next(34000,40000));
                        Log("Scan Complete, Post auction items");
                        Post();
                    }
                }
                catch (Exception e)
                {
                    Log(e.Message);
                    Log(e.Data.ToString());
                }
            }
        }
    }
}
